// @vue/component
import {roomCheckAdd} from "@/api/roomCheck";

export default {
  name: 'RoomCheck',

  components: {},

  mixins: [],

  props: {},

  data () {
    return {
      checkQuery:{
        phone:'',
        room_num:'',
        page_size:10,
        page_num:1,
        total:0
      },
      checkInShow:false,
      roomCheckInfo:{
        room_num:'',
        user_name:'',
        user_phone:'',
        start_date:this.getNowTime(),
        end_date:'',
      },

      pickerOptionsStart: {
        disabledDate(time) {
          return time.getTime() < Date.now();
        },
        shortcuts: [{
          text: '今天',
          onClick(picker) {
            picker.$emit('pick', new Date());
          }
        }, {
          text: '明天',
          onClick(picker) {
            const date = new Date();
            date.setTime(date.getTime() + 3600 * 1000 * 24);
            picker.$emit('pick', date);
          }
        }]
      },
      pickerOptionsEnd: {
        disabledDate(time) {
          return time.getTime() < Date.now();
        },
        shortcuts: [{
          text: '明天',
          onClick(picker) {
            const date = new Date();
            date.setTime(date.getTime() + 3600 * 1000 * 24);
            picker.$emit('pick', date);
          }
        }, {
          text: '后天',
          onClick(picker) {
            const date = new Date();
            date.setTime(date.getTime() + 3600 * 1000 * 24*2);
            picker.$emit('pick', date);
          }
        }]
      },


    }
  },

  computed: {},

  watch: {},

  created () {},

  methods: {
    getCheckList(){

    },
    checkAdd(){
      roomCheckAdd(this.roomCheckInfo).then(res=>{
        if (res.code === 200) {
          this.$notify({
            title: '成功', message: '入住登记添加成功', type: 'success', duration: 2000
          })
          this.checkInShow = false
          this.getCheckList();
        } else {
          this.$notify({
            title: '失败', message: res.message, type: 'error', duration: 2000
          })
        }
      })
    },
    getNowTime() {
      var now = new Date();
      var year = now.getFullYear(); //得到年份
      var month = now.getMonth(); //得到月份
      var date = now.getDate(); //得到日期
      month = month + 1;
      month = month.toString().padStart(2, "0");
      date = date.toString().padStart(2, "0");
      var defaultDate = `${year}-${month}-${date}`;
      return defaultDate;
    }

  }
}
